package org.loon.game.sample.llk.Map.xml;

import org.loon.framework.javase.game.core.graphics.LColor;
import org.loon.framework.javase.game.core.graphics.LImage;
import org.loon.framework.javase.game.core.graphics.component.LButton;
import org.loon.framework.javase.game.core.graphics.component.LLayer;
import org.loon.framework.javase.game.core.graphics.device.LGraphics;
import org.loon.framework.javase.game.core.graphics.opengl.GLColor;
import org.loon.framework.javase.game.core.graphics.opengl.GLEx;

public class PopMenu extends LLayer {
	
	int row= 4,clom=4;
	
	public PopMenu(int w, int h) {
		super(w, h);
		setLayer(101);
		// 不锁定menu移动
		setLocked(false);
		setLimitMove(false);
		// 锁定Actor拖拽
		setActorDrag(false);
		setDelay(500);
		// 设定Menu背景
		LImage image = LImage.createImage(this.getWidth(),
				this.getHeight(), true);
		LGraphics g = image.getLGraphics();
		g.setColor(0, 0, 0, 125);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(LColor.white);
		g.setFont(15);
		g.drawString("菜单", 12, 25);
		g.dispose();
		setBackground(image.getTexture());
		
		initUpDownButton();
	}
	
	private void initUpDownButton(){
		int wd = 24 ,h =24;
		LImage image = LImage.createImage(this.getWidth(),
				this.getHeight(), true);
		LGraphics g = image.getLGraphics();
		g.setColor(LColor.white);
		g.fillRect(0, 0,wd,h);
		g.setColor(LColor.red);
		g.drawLine(wd/2, 0, wd/2,h );
		g.drawLine(0, h/2, wd,h/2 );
		g.dispose();
		
		LImage image1 = LImage.createImage(this.getWidth(),
				this.getHeight(), true);
		LGraphics g1 = image1.getLGraphics();
		g1.setColor(LColor.white);
		g1.fillRect(0, 0,wd,h);
		g1.setColor(LColor.red);
		//g1.drawLine(wd/2, 0, wd/2,h );
		g1.drawLine(0, h/2, wd,h/2 );
		g1.dispose();
		
		LButton rowDown = new LButton(image.getTexture(),"",40,40){
			public void doClick(){
				row--;
			}
		};
		LButton rowUp = new LButton(image1.getTexture(),"",40,80){
			public void doClick(){
				row++;
			}
		};
		
		LButton colmDown = new LButton(image.getTexture(),"",90,40){
			public void doClick(){
				clom--;
			}
		};
		LButton colmUp = new LButton(image1.getTexture(),"",90,80){
			public void doClick(){
				clom++;
			}
		};
		add(rowDown);
		add(rowUp);
		add(colmDown);
		add(colmUp);
	}
	
	
	public void paint(GLEx g){
		g.setColor(GLColor.red);
		g.drawString("行:"+row, 40, 40);
		g.drawString("列:"+clom, 80, 40);
		g.resetColor();
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getClom() {
		return clom;
	}

	public void setClom(int clom) {
		this.clom = clom;
	}
	
	
	

}
